package com.qf.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.entity.AdminUser;
import com.qf.mapper.AdminUserMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Service
@Transactional
public class AdminUserServiceImpl implements AdminUserService {

    @Autowired
    private AdminUserMapper adminUserMapper;


    @Override
    public PageInfo<AdminUser> queryAll(int pageNum, int pageSize,Integer id, String email, Boolean status){
        PageHelper.startPage(pageNum,pageSize);
        List<AdminUser> adminUsers = adminUserMapper.queryAll(id, email, status);
        return new PageInfo<AdminUser>(adminUsers);
    }

    @Override
    @Transactional(propagation = Propagation.SUPPORTS)
    public AdminUser queryUserById(int id) {
        return adminUserMapper.queryUserById(id);
    }

    @Override
    public int insertUser(AdminUser adminUser) {
        return adminUserMapper.insertUser(adminUser);
    }

    @Override
    public int deleteUser(int id) {
        return adminUserMapper.deleteUser(id);
    }

    @Override
    public int updateUser(AdminUser adminUser) {
        return adminUserMapper.updateUser(adminUser);
    }

    @Override
    public AdminUser login(AdminUser adminUser) {
        AdminUser login = adminUserMapper.login(adminUser);
        return login;
    }

    @Override
    public int delAdminUser(int ids[]) {
        int delAdminUser = adminUserMapper.delAdminUser(ids);
        return delAdminUser;
    }


}

